package gui.windows.components;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

import cardmanager.CardInfo;

@SuppressWarnings("serial")
public class CardCellRenderer extends JLabel implements ListCellRenderer<Object> {
	@Override
	public Component getListCellRendererComponent(JList<?> list, Object value,
			int index, boolean isSelected, boolean cellHasFocus) {

		CardInfo card = (CardInfo)value;
		this.setText(card.getName() + " x" + card.count);

		this.setOpaque(true);
		
		if(isSelected){
			this.setForeground(Color.white);  
			this.setBackground(Color.black);
		}
		else{
			this.setForeground(Color.black);  
			this.setBackground(Color.white);
		}

		return this;
	}
}
